package com.itcast.demo_one.kotlin

fun main() {
  // 1. 基本的遍历 1-10
  for (i in 1..10){
      print(i)
  }

  println()
  println("-------------")

  // 2. 遍历 1-10 用until
  for (i in 1 until 11){
      print(i)
  }

  println()
  println("-------------")

  // 3. 遍历 1-10 用step
  for (i in 1..10 step 2){
      print(i)
  }

  println()
  println("-------------")

  // 4. 降序遍历
  for (i in 50 downTo 1 step 2){
      print(i)
  }

  val myList = listOf("张三", "李四", "王五")
  for (i in myList){
      print(i)
  }
  myList.forEach { print(it) }
}